
#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__': 
    from wlstModule import *#@UnusedWildImport

def getRunningServerNames():
    domainConfig()
    return cmo.getServers()

def monitorRunningServers():
    username = 'weblogic'
    password = 'weblogic'
    url='t3://cgappt41.qcorpaa.aa.com:7005'
    connect(username,password,url)
    
    edit()
    startEdit()
    
    cd('/')
    cmo.createUnixMachine('cgappt41.qcorpaa.aa.com')

    cd('/Machines/cgappt41.qcorpaa.aa.com/NodeManager/cgappt41.qcorpaa.aa.com')
    cmo.setNMType('Plain')
    cmo.setListenPort(5556)
    cmo.setListenAddress('10.62.60.27')
    cmo.setDebugEnabled(false)
    
    cd('/Servers/AflsAdmSer')
    cmo.setMachine(getMBean('/Machines/cgappt41.qcorpaa.aa.com'))   
    
    try:
        save()
        activate(block="true")
        print "script returns SUCCESS"   
    except Exception, e:
        print e 
        print "Error while trying to save and/or activate!!!"
        dumpStack()
        raise 
    


if __name__== "main":
    monitorRunningServers()
    
